#include <Uefi.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>

extern VOID AsmBreakpoint(VOID);

VOID
MyEnventNotify(EFI_EVENT Event, VOID *Context)
{
  STATIC UINTN Times = 0;
  Print(L"MyEnventNotify Wait %d\n", Times);

  Times++;
  if (Times > 5) {

    gBS->SignalEvent(Event);
  }
}

EFI_STATUS
TestNotify()
{
  EFI_STATUS Status = EFI_SUCCESS;
  UINTN Index       = 0;
  EFI_EVENT MyEvent = { 0 };

  Status = gBS->CreateEvent(EVT_NOTIFY_WAIT, TPL_NOTIFY, MyEnventNotify, NULL, &MyEvent);
  Status = gBS->WaitForEvent(1, &MyEvent, &Index);

  return EFI_SUCCESS;
}

EFI_STATUS
UefiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_STATUS Status = EFI_SUCCESS;

  AsmBreakpoint();

  // CpuBreakpoint();

  return TestNotify();
}